//
//  SNReturnGoodsView.m
//  app
//
//  Created by 王少宁 on 15/5/15.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNReturnGoodsView.h"

@implementation SNReturnGoodsView

- (instancetype)initWithFrame:(CGRect)frame sn:(NSString *)sn createTime:(NSString *)createTime receiver:(NSString *)receiver isReturns:(NSString *)isReturns ostatus:(NSString *)ostatus
{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel * createTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-90, frame.size.height-65, 90-UF(24), 20)];
        createTimeLabel.font = JKAppGlobleFontMinTagText;
        createTimeLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];
        createTimeLabel.textAlignment = NSTextAlignmentRight;
        createTimeLabel.text = createTime;
        [self addSubview:createTimeLabel];
        
        UILabel * snLabel = CREATE_WITH_FRAME_OF(UILabel, [self.ufo ux:24 oy:createTimeLabel.ufo.y],
                                                 [createTimeLabel.ubo uw:-24 ow:createTimeLabel.ufo.x fh:1.0]);
        snLabel.font = JKAppGlobleFontMinTagText;
        snLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];
        snLabel.text = [NSString stringWithFormat:@"订单号 : %@",sn];
        [self addSubview:snLabel];
        
        UILabel * receiverLabel = CREATE_WITH_FRAME_OF(UILabel, [snLabel.ufo fx:0 fy:1.0 oy:12],
                                                       [snLabel.ubo fw:1.0 fh:1.0 oh:5]);
        receiverLabel.font = JKAppGlobleFontMinTagText;
        receiverLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];
        receiverLabel.text = [NSString stringWithFormat:@"收货人 : %@",receiver];
        [self addSubview:receiverLabel];
        
        UILabel * ostatusLabel = CREATE_WITH_FRAME_OF(UILabel, [createTimeLabel.ufo fx:0 fy:1.0 oy:8],
                                                      [createTimeLabel.ubo fw:1.0 oh:27]);
        ostatusLabel.font = JKAppGlobleFontMinTagText;
        ostatusLabel.textAlignment = NSTextAlignmentRight;
        ostatusLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];

        
        if ([isReturns intValue] == 0) {
            switch ([ostatus intValue]) {
                case 0:
                    ostatusLabel.text = @"未支付";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#FC3E53"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#FC3E53"];
                    break;
                case 1:
                    ostatusLabel.text = @"支付成功";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#FF8018"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#FF8018"];
                    break;
                case 2:
                    ostatusLabel.text = @"已发货";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#FF8018"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#FF8018"];
                    break;
                case 4:
                    ostatusLabel.text = @"已签收";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#FF8018"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#FF8018"];
                    break;
                case 5:
                    ostatusLabel.text = @"已失效";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#888888"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#888888"];
                    break;
                case 6:
                    ostatusLabel.text = @"订单取消";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#888888"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#888888"];
                    break;
                case 8:
                    ostatusLabel.text = @"备货中";
//                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#888888"].CGColor;
//                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#888888"];
                    break;
                case 9:
                    ostatusLabel.text = @"备货中";
                    //                    ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#888888"].CGColor;
                    //                    ostatusLabel.textColor = [XCommon hexStringToColor:@"#888888"];
                    break;
                default:
                    break;
            }
        } else {
            ostatusLabel.text = @"售后中";
//            ostatusLabel.layer.borderColor = [XCommon hexStringToColor:@"#888888"].CGColor;
//            ostatusLabel.textColor = [XCommon hexStringToColor:@"#888888"];
        }
        
        
        [self addSubview:ostatusLabel];
        
    }
    return self;
}

+ (instancetype)viewWithFrame:(CGRect)frame sn:(NSString *)sn createTime:(NSString *)createTime receiver:(NSString *)receiver isReturns:(NSString *)isReturns ostatus:(NSString *)ostatus
{
    return [[self alloc] initWithFrame:frame sn:sn createTime:createTime receiver:receiver isReturns:isReturns ostatus:ostatus];
}

- (void)drawRect:(CGRect)rect
{
    [self drawBackground:rect color:[XCommon hexStringToColor:kColor_m_light_gray_background]];
    [self drawSeperatorLineLeft:UF(24) right:0];
}

@end
